cmake_minimum_required(VERSION 3.15)
project("fmm2d" LANGUAGES "Fortran")

# 添加子目录
add_subdirectory(dgmres)

file(GLOB fmm_src *.f90)

add_compile_options(-std=legacy -fallow-argument-mismatch -g)
add_executable(${CMAKE_PROJECT_NAME} ${fmm_src})
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/dgmres/lib")
target_link_libraries(${PROJECT_NAME} PRIVATE dgmres)

# add_dependencies(${CMAKE_PROJECT_NAME} input_dat)

# -------------------------------------------
file(GLOB input_file input.dat input.fmm)
message(${input_file} ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(
    TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy
    ${input_file}
    ${CMAKE_CURRENT_BINARY_DIR}
)
